package com.appwoo.txtws.activity;

import android.app.Dialog;
import android.content.Context;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.adapter.ListViewCreator;
import com.appwoo.txtws.adapter.Page;
import com.appwoo.txtws.adapter.SimpleListAdapter;
import com.appwoo.txtws.app.App;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.Record_SoftBean;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.SoftLimitService;
import com.appwoo.txtws.service.WebLimitService;
import com.appwoo.txtws.wheel.widget.PageListView;
import com.appwoo.txtws.wheel.widget.PageListView.OnRefreshListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

public class PCSoftsManager extends AppActivity
{
  private boolean blDataTask;
  private Button button;
  private TextView delete;
  private List<Record_SoftBean> events;
  private int flag = 0;
  private boolean isFoot;
  private boolean isLimit = true;
  private TextView keep_setting;
  private List<Record_SoftBean> newlist;
  private RelativeLayout no_info;
  private Page<Record_SoftBean> page = new Page();
  private RelativeLayout rl;
  private RadioButton softLimit;
  private RadioButton softStyle;
  private SimpleListAdapter<Record_SoftBean> softs_adapter;
  private PageListView softs_limit;
  private PageListView softs_style;
  private TextView text_alert;

  private void SetSoftEvent(int paramInt)
  {
    for (int i = 0; ; i++)
    {
      if (i >= this.page.getEntries().size())
      {
        this.softs_adapter.notifyDataSetChanged();
        return;
      }
      ((Record_SoftBean)this.page.getEntries().get(i)).setFlag_id(paramInt);
    }
  }

  private void addAllSoftSite()
  {
    for (int i = 0; ; i++)
    {
      if (i >= this.page.getEntries().size())
      {
        this.softs_adapter.notifyDataSetChanged();
        return;
      }
      if (!this.newlist.contains(this.page.getEntries().get(i)))
        this.newlist.add((Record_SoftBean)this.page.getEntries().get(i));
    }
  }

  private void initActionBar()
  {
    setBarTitle(getResources().getString(2131428142));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        PCSoftsManager.this.finish();
      }
    });
    setBarHomeText(getResources().getString(2131427535));
    showBarHomeBtn(Boolean.valueOf(true));
    this.button = ((Button)findViewById(2131492864).findViewById(2131493279));
    this.button.setBackgroundDrawable(getResources().getDrawable(2130838112));
    LinearLayout.LayoutParams localLayoutParams = (LinearLayout.LayoutParams)this.button.getLayoutParams();
    localLayoutParams.height = 50;
    localLayoutParams.width = 85;
    this.button.setLayoutParams(localLayoutParams);
    this.button.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        if (PCSoftsManager.this.flag == 0)
        {
          PCSoftsManager.this.setBarHomeText(PCSoftsManager.this.getResources().getString(2131428135));
          PCSoftsManager.this.flag = 1;
          PCSoftsManager.this.delete.setVisibility(0);
          PCSoftsManager.this.delete.setText(PCSoftsManager.this.getString(2131427535));
          PCSoftsManager.this.rl.setBackgroundColor(PCSoftsManager.this.getResources().getColor(2131230730));
          PCSoftsManager.this.keep_setting.setVisibility(8);
          PCSoftsManager.this.softs_adapter.notifyDataSetChanged();
        }
        do
        {
          return;
          if (PCSoftsManager.this.flag == 1)
          {
            PCSoftsManager.this.setBarHomeText(PCSoftsManager.this.getResources().getString(2131427514));
            PCSoftsManager.this.addAllSoftSite();
            PCSoftsManager.this.SetSoftEvent(1);
            PCSoftsManager.this.delete.setText("删除 （" + PCSoftsManager.this.newlist.size() + "）项");
            PCSoftsManager.this.flag = 2;
            return;
          }
          if (PCSoftsManager.this.flag == 2)
          {
            PCSoftsManager.this.flag = 3;
            PCSoftsManager.this.removeAllSoftSite();
            PCSoftsManager.this.SetSoftEvent(0);
            PCSoftsManager.this.delete.setText("删除 （" + PCSoftsManager.this.newlist.size() + "）项");
            return;
          }
        }
        while (PCSoftsManager.this.flag != 3);
        PCSoftsManager.this.delete.setVisibility(8);
        PCSoftsManager.this.flag = 0;
        PCSoftsManager.this.rl.setBackgroundColor(PCSoftsManager.this.getResources().getColor(2131230728));
        PCSoftsManager.this.setBarHomeText(PCSoftsManager.this.getResources().getString(2131427535));
        PCSoftsManager.this.removeAllSoftSite();
        PCSoftsManager.this.SetSoftEvent(0);
      }
    });
  }

  private void initAdapter()
  {
    if (this.isLimit)
    {
      this.softs_adapter = new SimpleListAdapter(this.page.getEntries(), new ListViewCreator()
      {
        private int flag_id;

        public View createView(final Record_SoftBean paramAnonymousRecord_SoftBean, View paramAnonymousView, int paramAnonymousInt)
        {
          if (paramAnonymousView == null)
            paramAnonymousView = App.getLayoutInflater().inflate(2130903164, null);
          TextView localTextView1 = (TextView)paramAnonymousView.findViewById(2131493332);
          TextView localTextView2 = (TextView)paramAnonymousView.findViewById(2131493331);
          final CheckBox localCheckBox = (CheckBox)paramAnonymousView.findViewById(2131493011);
          if (PCSoftsManager.this.flag == 0)
          {
            localCheckBox.setVisibility(8);
            this.flag_id = paramAnonymousRecord_SoftBean.getFlag_id();
            if (this.flag_id != 1)
              break label131;
            localCheckBox.setChecked(true);
          }
          while (true)
          {
            localTextView1.setText(paramAnonymousRecord_SoftBean.getGameName());
            localTextView2.setText(paramAnonymousRecord_SoftBean.getVisitedTime());
            localCheckBox.setOnClickListener(new View.OnClickListener()
            {
              public void onClick(View paramAnonymous2View)
              {
                if (localCheckBox.isChecked())
                {
                  paramAnonymousRecord_SoftBean.setFlag_id(1);
                  PCSoftsManager.this.newlist.add(paramAnonymousRecord_SoftBean);
                  PCSoftsManager.this.delete.setText("删除（" + PCSoftsManager.this.newlist.size() + "）项");
                  return;
                }
                paramAnonymousRecord_SoftBean.setFlag_id(0);
                if (PCSoftsManager.this.newlist.contains(paramAnonymousRecord_SoftBean))
                  PCSoftsManager.this.newlist.remove(paramAnonymousRecord_SoftBean);
                PCSoftsManager.this.delete.setText("删除（" + PCSoftsManager.this.newlist.size() + "）项");
              }
            });
            return paramAnonymousView;
            localCheckBox.setVisibility(0);
            break;
            label131: localCheckBox.setChecked(false);
          }
        }
      });
      this.softs_limit.setAdapter(this.softs_adapter);
      this.softs_limit.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener()
      {
        public boolean onItemLongClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
        {
          if (PCSoftsManager.this.flag == 0)
          {
            PCSoftsManager.this.newlist.add((Record_SoftBean)PCSoftsManager.this.page.getEntries().get(paramAnonymousInt));
            PCSoftsManager.this.showDialog(PCSoftsManager.this);
          }
          return false;
        }
      });
      this.softs_limit.setOnScrollListener(new AbsListView.OnScrollListener()
      {
        public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
        {
        }

        public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
        {
          if ((paramAnonymousInt == 0) && (paramAnonymousAbsListView.getLastVisiblePosition() == -1 + paramAnonymousAbsListView.getCount()) && (!PCSoftsManager.this.softs_limit.getIsNoMore()) && (PCSoftsManager.this.blDataTask))
          {
            PCSoftsManager.this.softs_limit.prepareForRefreshMore();
            PCSoftsManager.this.isFoot = false;
            PCSoftsManager.this.loadingData(false);
          }
        }
      });
      this.softs_limit.setOnLoadMoreListener(new PageListView.OnRefreshListener()
      {
        public void onRefresh()
        {
          PCSoftsManager.this.softs_limit.prepareForRefreshMore();
          PCSoftsManager.this.isFoot = false;
          PCSoftsManager.this.loadingData(true);
        }
      });
      addOperation(new DataTask().execute(new String[] { "softlimit" }));
    }
  }

  private void initView()
  {
    this.newlist = new ArrayList();
    this.softLimit = ((RadioButton)findViewById(2131493333));
    this.softStyle = ((RadioButton)findViewById(2131493334));
    this.softs_limit = ((PageListView)findViewById(2131493335));
    this.softs_style = ((PageListView)findViewById(2131493336));
    this.no_info = ((RelativeLayout)findViewById(2131493337));
    this.keep_setting = ((TextView)findViewById(2131493338));
    this.delete = ((TextView)findViewById(2131493339));
    this.rl = ((RelativeLayout)findViewById(2131493019));
    this.softLimit.setChecked(true);
    this.softs_style.setVisibility(8);
    this.softs_limit.setVisibility(8);
    this.no_info.setVisibility(8);
    this.text_alert = ((TextView)findViewById(2131493022));
    this.keep_setting.setVisibility(8);
    this.keep_setting.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
      }
    });
    this.softLimit.setOnClickListener(new View.OnClickListener()
    {
      private boolean isLimitClick;

      public void onClick(View paramAnonymousView)
      {
        PCSoftsManager.this.flag = 0;
        PCSoftsManager.this.isFoot = false;
        PCSoftsManager.this.blDataTask = true;
        PCSoftsManager.this.isLimit = true;
        PCSoftsManager.this.button.setText(PCSoftsManager.this.getResources().getString(2131427535));
        PCSoftsManager.this.button.setVisibility(0);
        PCSoftsManager.this.keep_setting.setVisibility(8);
        PCSoftsManager.this.softs_style.setVisibility(8);
        PCSoftsManager.this.softs_limit.setVisibility(8);
        PCSoftsManager.this.no_info.setVisibility(8);
        if ((!this.isLimitClick) && (PCSoftsManager.this.page.getEntries().size() == 0))
        {
          PCSoftsManager.this.no_info.setVisibility(0);
          this.isLimitClick = true;
        }
        do
        {
          return;
          if ((!this.isLimitClick) && (PCSoftsManager.this.page.getEntries().size() != 0))
          {
            PCSoftsManager.this.softs_limit.setVisibility(0);
            this.isLimitClick = true;
            return;
          }
          if ((this.isLimitClick) && (PCSoftsManager.this.page.getEntries().size() == 0))
          {
            PCSoftsManager.this.no_info.setVisibility(0);
            return;
          }
        }
        while ((!this.isLimitClick) || (PCSoftsManager.this.page.getEntries().size() == 0));
        PCSoftsManager.this.softs_limit.setVisibility(0);
      }
    });
    this.softStyle.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        PCSoftsManager.this.isFoot = false;
        PCSoftsManager.this.blDataTask = true;
        PCSoftsManager.this.isLimit = false;
        PCSoftsManager.this.removeAllSoftSite();
        PCSoftsManager.this.SetSoftEvent(0);
        PCSoftsManager.this.button.setVisibility(8);
        PCSoftsManager.this.delete.setVisibility(8);
        PCSoftsManager.this.keep_setting.setVisibility(0);
        PCSoftsManager.this.rl.setBackgroundColor(PCSoftsManager.this.getResources().getColor(2131230728));
        PCSoftsManager.this.softs_style.setVisibility(8);
        PCSoftsManager.this.softs_limit.setVisibility(8);
        PCSoftsManager.this.no_info.setVisibility(8);
      }
    });
  }

  private void loadingData(boolean paramBoolean)
  {
    if (this.isLimit)
    {
      if (!paramBoolean)
        break label44;
      this.page.firstPage();
    }
    while (true)
    {
      addOperation(new DataTask().execute(new String[] { "softslimit" }));
      return;
      label44: this.page.nextPage();
    }
  }

  private void removeAllSoftSite()
  {
    for (int i = 0; ; i++)
    {
      if (i >= this.page.getEntries().size())
        return;
      this.newlist.remove(this.page.getEntries().get(i));
    }
  }

  protected void backKeyCallBack()
  {
    finish();
  }

  public void onBackPressed()
  {
    finish();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903166);
    initActionBar();
    initView();
    initAdapter();
  }

  protected void showDialog(Context paramContext)
  {
    View localView = getLayoutInflater().inflate(2130903082, null);
    final Dialog localDialog = new Dialog(paramContext, 2131361814);
    localDialog.setContentView(localView);
    ((TextView)localView.findViewById(2131492904));
    TextView localTextView1 = (TextView)localView.findViewById(2131493069);
    TextView localTextView2 = (TextView)localView.findViewById(2131493068);
    localTextView1.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        localDialog.dismiss();
      }
    });
    localTextView2.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        try
        {
          if (localDialog.isShowing())
            localDialog.dismiss();
          new PCSoftsManager.DataTask(PCSoftsManager.this).execute(new String[] { "delsofts" });
          return;
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }
    });
    localDialog.show();
  }

  class DataTask extends AsyncTask<String, Integer, String>
  {
    private String TAG;
    private StateBean bean;
    private String bid;
    private String param;
    private String userid;
    private String userpwd;

    DataTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.param = paramArrayOfString[0];
      RqSP localRqSP = new RqSP();
      this.userid = localRqSP.getLgDevAccount(PCSoftsManager.this);
      this.bid = localRqSP.getLgDevId(PCSoftsManager.this);
      this.userpwd = localRqSP.getLgPwd(PCSoftsManager.this);
      Log.v(this.TAG, this.userid);
      Log.v(this.TAG, this.bid);
      try
      {
        if (this.param.equals("softlimit"))
          PCSoftsManager.this.events = new WebLimitService().getGameBlackList(this.userid, this.bid, PCSoftsManager.this.page.getPageNo(), PCSoftsManager.this);
        else if (this.param.equals("delsofts"))
          this.bean = new SoftLimitService().delCommitgame(this.userid, this.bid, PCSoftsManager.this.newlist, PCSoftsManager.this);
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace();
      }
      catch (XmlPullParserException localXmlPullParserException)
      {
        localXmlPullParserException.printStackTrace();
      }
      catch (TimeOutException localTimeOutException)
      {
        localTimeOutException.printStackTrace();
      }
      catch (NotFoundNetWorkException localNotFoundNetWorkException)
      {
        localNotFoundNetWorkException.printStackTrace();
      }
      return null;
    }

    protected void onPostExecute(String paramString)
    {
      if (this.param.equals("softlimit"))
        if ((PCSoftsManager.this.events != null) && (PCSoftsManager.this.events.size() > 0))
        {
          PCSoftsManager.this.page.addAllEntries(PCSoftsManager.this.events);
          PCSoftsManager.this.softs_limit.setVisibility(0);
          PCSoftsManager.this.softs_adapter.notifyDataSetChanged();
          PCSoftsManager.this.softs_limit.hideFotterMoreView();
          PCSoftsManager.this.softs_limit.setIsNoMore(true);
          PCSoftsManager.this.softs_limit.onLoadMoreComplete();
          if (PCSoftsManager.this.events.size() < PCSoftsManager.this.page.getPageSize())
          {
            PCSoftsManager.this.softs_limit.hideFotterMoreView();
            PCSoftsManager.this.softs_limit.setIsNoMore(true);
          }
          PCSoftsManager.this.events.clear();
          PCSoftsManager.this.blDataTask = true;
          PCSoftsManager.this.isFoot = true;
        }
      while (!this.param.equals("delsofts"))
        while (true)
        {
          if (PCSoftsManager.this.isFoot)
          {
            PCSoftsManager.this.closeProgress();
            PCSoftsManager.this.isFoot = false;
          }
          super.onPostExecute(paramString);
          return;
          if (PCSoftsManager.this.page.getEntries().size() == 0)
          {
            PCSoftsManager.this.no_info.setVisibility(0);
          }
          else
          {
            PCSoftsManager.this.softs_limit.hideFotterMoreView();
            PCSoftsManager.this.softs_limit.setIsNoMore(true);
          }
        }
      if (this.bean.getDesc().equals("成功"))
      {
        PCSoftsManager.this.page.getEntries().removeAll(PCSoftsManager.this.newlist);
        PCSoftsManager.this.newlist.clear();
        PCSoftsManager.this.softs_adapter.notifyDataSetChanged();
        PCSoftsManager.this.alertMessage(PCSoftsManager.this.getResources().getString(2131427527));
      }
      while (true)
      {
        PCSoftsManager.this.blDataTask = true;
        PCSoftsManager.this.isFoot = true;
        break;
        PCSoftsManager.this.alertMessage(PCSoftsManager.this.getResources().getString(2131427528));
      }
    }

    protected void onPreExecute()
    {
      PCSoftsManager.this.blDataTask = false;
      if (!PCSoftsManager.this.isFoot)
        PCSoftsManager.this.showProgress("");
      super.onPreExecute();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.PCSoftsManager
 * JD-Core Version:    0.6.2
 */